package cn.k.interceptor;

import cn.k.domain.Employee;
import cn.k.util.UserContext;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class CheckLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //没有登录
        Employee employee = UserContext.getEmployee();
        if (employee==null){
            response.sendRedirect("/static/login.html");
            return false;
        }

        //登录成功
        return  true;
    }
}
